namespace PropertyExpression.ControllableQuery
{
    internal static class SqlParameterNameGenerator
    {
        private const int cachedParameterCount = 100;
        private static readonly string[] cachedParameterNames = new string[cachedParameterCount];
        static SqlParameterNameGenerator()
        {
            for (var i = 0; i < cachedParameterNames.Length; i++)
                cachedParameterNames[i] = GetName(i);
        }

        private static string GetName(int i)
        {
            return "@p" + i;
        }

        public static string GetNextName(int count)
        {
            return count < cachedParameterCount
                       ? cachedParameterNames[count]
                       : GetName(count);
        }
    }
}